<script>
import { mapState } from 'vuex'
import { zoneGetlistApi, reportViewpdfApi } from '@/requset/api'
import { formConfig, config, column } from './formConfig.js'
import SearchManage from '@/components/basic/SearchManage.vue'
import { requestApi } from '@/requset/api'
import { deepClone } from '@/plugins/clone'
export default {
    extends: SearchManage,
    data() {
        return {
            table_title: '菜单',
            url: 'menum',
            actions: [
                // {
                //     label: '批量删除',
                //     icon: 'el-icon-delete',
                //     click: () => {
                //         this.deletes()
                //     },
                //     if: () => this.operate,
                // },
                {
                    label: '添加',
                    icon: 'el-icon-folder-add',
                    click: () => {
                        this.handleAdd()
                    },
                    if: () => this.operate,
                },
            ],
            baseForm: {},
            queryForm: {
                page: 1,
                label: null,
                name: null,
                type: null,
            },

            queryFormC: {},
        }
    },
    methods: {
        searchBtn() {
            this.getlist()
        },
    },
    computed: {},
    created() {
        this.searchBtn()
        this.formConfig = formConfig
        config[3].onChange = (config, form) => {
            let { type } = form
            requestApi('post', 'menum/getlist', { type: type - 1, page: 1, size: 999 }).then((res) => {
                if (res.data.code == 0) {
                    config[4].options = res.data.data.map((item) => {
                        return {
                            label: item.label,
                            value: item.id,
                        }
                    })
                }
            })
        }
        this.dialog.config = config
        column[column.length - 1].buttons = [
            {
                text: '删除',
                click: (val) => this.delete(val),
                icon: 'el-icon-delete',
            },
            {
                text: '编辑',
                click: (val) => {
                    this.handleEdit(val)
                },
                icon: 'el-icon-edit',
            },
        ]
        column[column.length - 1].if = this.operate
        this.tableColumn = column
    },
}
</script>
